import { Body, Controller, Get, Post } from '@nestjs/common';
import { AppService } from './app.service';

@Controller()
export class AppController {
    constructor(private readonly appService: AppService) { }

    @Get()
    getHello(): string {
        return this.appService.getHello();
    }

    @Post("img")
    async getImage(@Body() body: any) {
        console.log("get image")
        console.log(body)
        const n = await this.appService.downloadImage(body.poster)
        return { name: n };
    }

    @Post("video/download")
    async getVideo(@Body() body: any) {
        console.log(body);
        const n = await this.appService.downloadVideo(body);
        return { name: n };
    }

    @Post("video/upload")
    async sendVideo(@Body() body: any) {
        console.log(body);
        // video: link,   ...mp4
        // src: url,   /weer554
        // size: arr[0].size   480x1280
        const n = await this.appService.uploadVideo(body);
        return { name: n };
    }
}

// {
//   "server": "43.153.23.186",
//   "server_port": 9737,
//   "local_address": "127.0.0.1",
//   "local_port": 1080,
//   "password": "jsz04005301",
//   "timeout": 600,
//   "method": "aes-256-cfb"
// }